namespace CinemaDirector
{
	public class AudioTrack : GlobalTrack
	{
		public CinemaAudio[] AudioClips
		{
			get
			{
				return GetComponentsInChildren<CinemaAudio>();
			}
		}

		public override void SetTime(float time)
		{
			CinemaAudio[] audioClips = AudioClips;
			foreach (CinemaAudio cinemaAudio in audioClips)
			{
				float time2 = time - cinemaAudio.Firetime;
				cinemaAudio.SetTime(time2);
			}
		}

		public override void Pause()
		{
			CinemaAudio[] audioClips = AudioClips;
			foreach (CinemaAudio cinemaAudio in audioClips)
			{
				cinemaAudio.Pause();
			}
		}

		public override void UpdateTrack(float time, float deltaTime)
		{
			float num = elapsedTime;
			elapsedTime = time;
			CinemaAudio[] audioClips = AudioClips;
			foreach (CinemaAudio cinemaAudio in audioClips)
			{
				if (cinemaAudio != null)
				{
					if ((num < cinemaAudio.Firetime || num <= 0f) && elapsedTime >= cinemaAudio.Firetime)
					{
						cinemaAudio.Trigger();
					}
					if (elapsedTime > cinemaAudio.Firetime && elapsedTime <= cinemaAudio.Firetime + cinemaAudio.Duration)
					{
						float time2 = time - cinemaAudio.Firetime;
						cinemaAudio.UpdateTime(time2, deltaTime);
					}
					if (num <= cinemaAudio.Firetime + cinemaAudio.Duration && elapsedTime > cinemaAudio.Firetime + cinemaAudio.Duration)
					{
						cinemaAudio.End();
					}
				}
			}
		}

		public override void Resume()
		{
			CinemaAudio[] audioClips = AudioClips;
			foreach (CinemaAudio cinemaAudio in audioClips)
			{
				if (base.Cutscene.RunningTime > cinemaAudio.Firetime && base.Cutscene.RunningTime < cinemaAudio.Firetime + cinemaAudio.Duration)
				{
					cinemaAudio.Resume();
				}
			}
		}

		public override void Stop()
		{
			elapsedTime = 0f;
			CinemaAudio[] audioClips = AudioClips;
			foreach (CinemaAudio cinemaAudio in audioClips)
			{
				cinemaAudio.Stop();
			}
		}
	}
}
